package com.itheima.demo;

import com.itheima.domain.User;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.util.List;

public class Demo {
    public static void main(String[] args)throws Exception {
        SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(Resources.getResourceAsStream("sql.xml"));
        SqlSession session = factory.openSession();
//      查询所有
        /*List <User> list = session.selectList("com.itheima.mapper.UserMapper.findAll");
        System.out.println(list);*/

//        根据email查询
       User user = session.selectOne("com.itheima.mapper.UserMapper.findByEmail","123@qq.com");
        System.out.println(user);
        session.close();
    }
}
